package com.zq.jdbc;

import com.mysql.jdbc.StringUtils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

public class MyTest {
    public static void main(String[] args) throws IOException {
        //读取属性文件方式一
        /*ResourceBundle my = ResourceBundle.getBundle("my");
        String zq = my.getString("zq");
        System.out.println(zq);*/

        //读取属性文件方式二
       /* Properties properties = new Properties();
        InputStream inputStream = MyTest.class.getResourceAsStream("/my.properties");
        properties.load(inputStream);
        System.out.println(properties.get("zq"));*/

        //读取属性文件方式三(和第二种基本一样)
        /*Properties properties = new Properties();
        InputStream inputStream = MyTest.class.getClassLoader().getResourceAsStream("my.properties");
        properties.load(inputStream);
        System.out.println(properties.getProperty("zq"));*/

        Properties properties = new Properties();
        PropertyResourceBundle my = new PropertyResourceBundle(MyTest.class.getClassLoader().getResourceAsStream("my.properties"));
        System.out.println(my.getString("zq"));
    }
}
